package com.os.opencv.java.chapter2;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class MatPixel {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //创建一个简单的矩阵
        Mat m = Mat.eye(3, 3, CvType.CV_8UC1);

        //输出修改前的矩阵数据
        System.out.println(m.dump());
        System.out.println();

        //将第2行第2列的数值改为9
        m.put(1, 1, 9);
        m.put(1, 1, 255);
        //输出修改后的矩阵数据
        System.out.println(m.dump());
        System.out.println();

        //获取第2行第2列的像素值，存储在data数组中
        byte[] data = new byte[3];
        m.get(1, 1, data);
        //属猪像素值
        System.out.println(data[0]);


    }
}
